﻿using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.Utils;
using System.Drawing;

namespace ProtocolVN.Framework.Win
{
    public class HelpGridExt
    {
        #region Tao mau cho Footer
        /// <summary>
        /// Hàm định dạng font chữ, màu chữ, kiểu chữ, màu nền cho Footer
        /// </summary>
        /// <param name="gridView">Lưới áp dụng</param>
        /// <param name="fieldFooters">Danh sách các cột áp dụng (fieldname)</param>
        /// <param name="foreColor">Màu chữ</param>
        /// <param name="backColor">Màu nền</param>
        /// <param name="fontStyle">Kiểu chữ</param>
        public static void SetFontFooter(GridView gridView, string[] fieldFooters, Color foreColor, Color backColor, FontStyle fontStyle)
        {
            AppearanceDefault footerApp = new AppearanceDefault(foreColor, backColor,
                   new Font(AppearanceObject.DefaultFont, fontStyle));
            gridView.CustomDrawFooterCell += delegate(object sender, DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventArgs e)
            {
                foreach (string item in fieldFooters)
                {
                    if (e.Column.FieldName == item)
                        AppearanceHelper.Apply(e.Appearance, footerApp);
                }
            };
        }
        #endregion

        public static void SetFontFooter(AdvBandedGridView gridView, string[] fieldFooters, Color foreColor, Color backColor, FontStyle fontStyle)
        {
            AppearanceDefault footerApp = new AppearanceDefault(foreColor, backColor,
                   new Font(AppearanceObject.DefaultFont, fontStyle));
            gridView.CustomDrawFooterCell += delegate(object sender, DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventArgs e)
            {
                foreach (string item in fieldFooters)
                {
                    if (e.Column.FieldName == item)
                        AppearanceHelper.Apply(e.Appearance, footerApp);
                }
            };
        }
    }
}
